#ifndef CONTROL_H
#define CONTROL_H

#include "data.h"
#include<WiFi.h>
#include <WiFiClient.h>
#include <ArduinoJson.h>
#include <Servo.h>
#include <math.h>

class analyse_data;
//业务处理模块
//根据读取解析的内容的数据逻辑进行业务处理的编写，搭建业务处理流程框架.
class Control
{
    public:
        double rad2ang(double r);
        void location2ang();
        Control();
        void controlClaw();
        void controlClawFlag();
        void getserver(WiFiClient& sendClient);
        void getmsg(analyse_data Nowmsg);
        void wirte2Client();
        bool flag_start;
        bool flag_mode2;
    private: 
        WiFiClient* Client; 
        analyse_data msg;
        analyse_data default_msg;
        // 创建JSON对象
        StaticJsonDocument<100> jsonDoc;
        String jsonOutput;
        Servo servo;
        Servo mode2;
        //舵机的控制引脚
        int base_pin  = 12;
        int right_pin = 13;
        int left_pin  = 14;
        int claw_pin  = 27;
        
        //舵机的位置
        double base_pos  = 90;
        double right_pos = 90;
        double left_pos  = 90;
        double claw_pos  = 80;
        
        //舵机角度矫正
        double base_adj  = -4;
        double right_adj = 0;
        double left_adj  = 5;
        
        //舵机的速度（单位：角度/秒）
        double base_spd  = 90;
        double right_spd = 45;
        double left_spd  = 45;
        double claw_spd  = 30;
        
        //舵机的加速度（K值）
        double base_ke  = 0.6;
        double right_ke  = 0.6;
        double left_ke  = 0.6;
        double claw_ke  = 0;
        
        //关节角度
        double joint1_pos = 90;
        double joint2_pos = 90;
        double joint3_pos = 90;
        double joint4_pos = 90;

  

};

#endif
